package cn.qiyu5522.domain.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * ClassName: LoginUser
 * Package: cn.qiyu5522.domain.entity
 * Description:
 *
 * @Author: Tonkey
 * @Create：2024/4/11-20:39
 * @Version: v1.0
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class LoginUser implements UserDetails, Serializable {

    private static final long serialVersionUID = 1L;

    private User user;
    private List<String> permissions;

//    private String password;
//
//    private String username;
//
//    private Set<GrantedAuthority> authorities;
//
//    private  boolean accountNonExpired;
//
//    private boolean accountNonLocked;
//
//    private boolean credentialsNonExpired;
//
//    private boolean enabled;



    @Override
    @JsonIgnore
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    @JsonIgnore
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    @JsonIgnore
    public String getUsername() {
        return user.getUserName();
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    @JsonIgnore
    public boolean isEnabled() {
        return true;
    }
}
